# Contributor: Joe Holden <jwh@zorins.us>
# Contributor: Michał Polański <michal@polanski.me>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=traefik
pkgver=2.8.1
pkgrel=0
pkgdesc="The Cloud Native Edge Router"
url="https://traefik.io/"
arch="all"
arch="$arch !x86 !armhf !armv7 !s390x !ppc64le" # failing tests
license="MIT"
makedepends="go go-bindata libcap"
install="$pkgname.pre-install"
pkgusers="$pkgname"
pkggroups="$pkgname"
subpackages="$pkgname-openrc"
options="chmod-clean"
source="$pkgname-$pkgver.tar.gz::https://github.com/containous/traefik/releases/download/v$pkgver/traefik-v$pkgver.src.tar.gz
	traefik.initd
	traefik.confd
	traefik.yaml
	rate-limiter-test.patch
	"
builddir="$srcdir"

# secfixes:
#   2.2.8-r0:
#     - CVE-2020-15129

build() {
	go generate
	go build \
		-v -o bin/$pkgname \
		./cmd/$pkgname
}

check() {
	go test ./...
}

package() {
	install -Dm755 bin/$pkgname "$pkgdir"/usr/sbin/$pkgname
	setcap cap_net_bind_service=+ep "$pkgdir"/usr/sbin/$pkgname

	install -Dm755 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
	install -Dm644 "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname

	install -dm750 -o $pkgname -g $pkgname "$pkgdir"/etc/$pkgname
	install -m644 -o $pkgname -g $pkgname "$srcdir"/traefik.yaml \
		"$pkgdir"/etc/$pkgname/$pkgname.yaml
}

sha512sums="
ce57c913aa91abdf92bb8538822e2963a9defd4e7cb8a0e87aa1dc9ea78129673a0c186f752fe48043fbc1bc1da8e74239f3280b4ebaf1680ed8b6c308157aeb  traefik-2.8.1.tar.gz
563175a94d31fc6b64729781b5749eb1fd76dd0203a877e605fb2135e4095c29e81dc1f0a708d38d21f9200fa20fd957dd858501a4473d9471f4056a60a9bd7c  traefik.initd
bbc0bb6825f8847ef0ee18b7194afc4e1443041727022e435e48249744b1230b3422ff9d20a6b42d2e3615e57c10254611fe1e999b847e7b4a4d5954bd677cf2  traefik.confd
6a31fe7d65d7b6676a9390aabe08db512d49692b327da6f28f7b3c0398472703568e5d2541a8136f409fc52473f18711437b260f104407aa08da358534fccccf  traefik.yaml
d09f8538873cc5997de1bf26245a8180c923a69ccfa869d97291d91d7190be40214243631b3ebd8d9cfdb5d39100c26529719bc6c7019e48a07052df475bd436  rate-limiter-test.patch
"
